package com.xdf.zipperdye.controller;

import com.xdf.zipperdye.model.Material;
import com.xdf.zipperdye.service.MaterialService;
import com.xdf.zipperdye.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "原料")
@CrossOrigin
@RestController
@RequestMapping("/material")
public class MaterialController {
    @Autowired
    private MaterialService service;

    @ApiOperation(value="根据主键删除数据", notes="根据主键删除数据", produces="application/json")
    @GetMapping("/deleteByPrimaryKey/{iid}")
    public JsonResult deleteByPrimaryKey(@PathVariable Integer iid){
        return JsonResult.ok(service.deleteByPrimaryKey(iid));
    }

    @ApiOperation(value="完全性新增", notes="完全性新增", produces="application/json")
    @PostMapping("/insert")
    public JsonResult insert(@RequestBody Material record){
        return JsonResult.ok(service.insert(record));
    }

    @ApiOperation(value="选择性新增", notes="选择性新增", produces="application/json")
    @PostMapping("/insertSelective")
    public JsonResult insertSelective(@RequestBody Material record){
        return JsonResult.ok(service.insertSelective(record));
    }

    @ApiOperation(value="根据主键查询", notes="根据主键查询", produces="application/json")
    @GetMapping("/selectByPrimaryKey/{iid}")
    public JsonResult selectByPrimaryKey(@PathVariable Integer iid){
        return JsonResult.ok(service.selectByPrimaryKey(iid));
    }

    @ApiOperation(value="选择性修改", notes="选择性修改", produces="application/json")
    @PostMapping("/updateByPrimaryKeySelective")
    public JsonResult updateByPrimaryKeySelective(@RequestBody Material record){
        return JsonResult.ok(service.updateByPrimaryKeySelective(record));
    }

    @ApiOperation(value="完全性修改", notes="完全性修改", produces="application/json")
    @PostMapping("/updateByPrimaryKey")
    public JsonResult updateByPrimaryKey(@RequestBody Material record){
        return JsonResult.ok(service.updateByPrimaryKey(record));
    }

    @ApiOperation(value="查询获取所有", notes="查询获取所有", produces="application/json")
    @GetMapping("/selectAll")
    public JsonResult selectAll(){
        return JsonResult.ok(service.selectAll());
    }
}
